file chooser: Avoid warnings from the location column
authorMatthias Clasen <mclasen@redhat.com>
Mon, 2 Mar 2015 20:38:29 +0000 (15:38 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 2 Mar 2015 21:25:30 +0000 (16:25 -0500)
Avoid criticals that would come out of this code if file is / or NULL.

gtk/gtkfilechooserwidget.c

index bd39b8d8ef95aa7f7f90c4a4de6f574ead6f01dd..0f39ca2ed92a834c3f558576ea2a173dcdb2d366 100644 (file)
@@ -4066,11 +4066,14 @@ file_system_model_set (GtkFileSystemModel *model,
         gchar *location;
 
         home_location = g_file_new_for_path (g_get_home_dir ());
-        dir_location = g_file_get_parent (file);
+        if (file)
+          dir_location = g_file_get_parent (file);
+        else
+          dir_location = NULL;
 
-        if (g_file_equal (home_location, dir_location))
+        if (dir_location && g_file_equal (home_location, dir_location))
           location = g_strdup (_("Home"));
-        else if (g_file_has_prefix (dir_location, home_location))
+        else if (dir_location && g_file_has_prefix (dir_location, home_location))
           {
             gchar *relative_path;
 
@@ -4084,7 +4087,8 @@ file_system_model_set (GtkFileSystemModel *model,
 
         g_value_take_string (value, location);
 
-        g_object_unref (dir_location);
+        if (dir_location)
+          g_object_unref (dir_location);
         g_object_unref (home_location);
       }
       break;